<?php
namespace jy_jd;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	/*
		订单状态UP
	*/
	public function orderup($ismanage=false){
		$order = pdo_getall('jy_jd_order',array('endtime'=>0,'intime <>'=>'','uniacid'=>$_SESSION['uniacid']));
		if($order){
			foreach($order as $a){
				$endtime=strtotime($a['intime'])+13*3600;
				if($a['day']){
					$endtime +=$a['day']*24*3600;
				}
				pdo_update('jy_jd_order',array('endtime'=>$endtime),array('id'=>$a['id'],'uniacid'=>$_SESSION['uniacid']));
			}
		}
		$setting=$this->plugin_setting('setting');
		$params=array('uniacid'=>$_SESSION['uniacid']);
		$pindex = max(1, 0);
		$psize = 10;
		$total='';
		if(!$ismanage){
			$params['mid']=$_SESSION['uid'];
		}
		//到时间退房
		$params['status']=6;
		$order5time=intval($setting['order5time'])?:24;
		$order5_outtime=TIMESTAMP-intval($order5time)*3600;
		$params['endtime <']=$order5_outtime;
		$order = pdo_getslice('jy_jd_order',$params,array($pindex,$psize),$total,array('id'));
		if($order){
			foreach($order as $a){
				if($a['id']){
					pdo_update('jy_jd_order',array('status'=>5),array('id'=>$a['id'],'uniacid'=>$_SESSION['uniacid']));
					$this->model('notice')->notice_tuifang($a);
				}		
			}
		}
		return false;
	}
}